#include <iostream>
#include <cstdio>
#include <stack>

using namespace std;

const int N = 3e6 + 10;

int n;

int q[N], ans[N];
stack<int> stk;

int main()
{
	scanf("%d", &n);
	
	for (int i = 1; i <= n; i ++ ) scanf("%d", &q[i]);
	
	for (int i = n; i > 0; i -- )
	{
		while (!stk.empty() && q[stk.top()] <= q[i]) stk.pop();
		
		if (stk.empty()) ans[i] = 0;
		else ans[i] = stk.top();
		
		stk.push(i);
	}
	
	
	for (int i = 1; i <= n; i ++ ) cout << ans[i] << ' ';
	
	return 0;
}